package com.ddw.meedeeuh.shared.movie.database;

import java.util.Map;

import com.ddw.meedeeuh.shared.io.SourceFile;
import com.ddw.meedeeuh.shared.io.SourceFolder;

public abstract class DBMovieFactory {

	public static DBMovie create(int movieId, String name, Integer year, String originalTitle,
			String sortTitle, String set, Double rating, Boolean top250, Integer votes,
			String outline, String plot, String tagline, Integer runtime, String thumbnail,
			String mpaa, Integer playCount, String imdbId, SourceFolder folder, String trailer,
			String genre, String credits, String director, Boolean watched,
			Map<Integer, DBStreamDetails> streamDetails, Map<Integer, DBActor> actors,
			SourceFile nfo, SourceFile poster, SourceFile fanart, Map<Integer, DBExtraThumb> extraThumbs) {
		if(name == null) {
			throw new IllegalArgumentException("The name parameter cannot be null");
		}
		if(streamDetails == null) {
			throw new IllegalArgumentException("The stream details parameter cannot be null");
		}
		if(actors == null) {
			throw new IllegalArgumentException("The actors parameter cannot be null");
		}
		if(folder == null) {
			throw new IllegalArgumentException("The folder parameter cannot be null");
		}
		if(extraThumbs == null) {
			throw new IllegalArgumentException("The extra thumbs parameter cannot be null");
		}

		return new DBMovieImpl(movieId, name, year, originalTitle, sortTitle, set, rating,
				top250, votes, outline, plot, tagline, runtime, thumbnail, mpaa, playCount,
				imdbId, folder, trailer, genre, credits, director, watched, streamDetails, actors,
				nfo, poster, fanart, extraThumbs);
	}

	private static class DBMovieImpl implements DBMovie {

		private final int movieId;
		private final String name;
		private final Integer year;
		private final String originalTitle;
		private final String sortTitle;
		private final String set;
		private final Double rating;
		private final Boolean top250;
		private final Integer votes;
		private final String outline;
		private final String plot;
		private final String tagline;
		private final Integer runtime;
		private final String thumbnail;
		private final String mpaa;
		private final Integer playCount;
		private final String imdbId;
		private final String trailer;
		private final String genre;
		private final String credits;
		private final String director;
		private final Boolean watched;
		private final Map<Integer, DBStreamDetails> streamDetails;
		private final Map<Integer, DBActor> actors;
		private final SourceFolder folder;
		private final SourceFile nfo;
		private final SourceFile fanart;
		private final SourceFile poster;
		private final Map<Integer, DBExtraThumb> extraThumbs;

		public DBMovieImpl(int movieId, String name, Integer year, String originalTitle,
				String sortTitle, String set, Double rating, Boolean top250, Integer votes,
				String outline, String plot, String tagline, Integer runtime, String thumbnail,
				String mpaa, Integer playCount, String imdbId, SourceFolder folder, String trailer,
				String genre, String credits, String director, Boolean watched,
				Map<Integer, DBStreamDetails> streamDetails, Map<Integer, DBActor> actors,
				SourceFile nfo, SourceFile poster, SourceFile fanart, Map<Integer, DBExtraThumb> extraThumbs) {
			this.movieId = movieId;
			this.name = name;
			this.year = year;
			this.originalTitle = originalTitle;
			this.sortTitle = sortTitle;
			this.set = set;
			this.rating = rating;
			this.top250 = top250;
			this.votes = votes;
			this.outline = outline;
			this.plot = plot;
			this.tagline = tagline;
			this.runtime = runtime;
			this.thumbnail = thumbnail;
			this.mpaa = mpaa;
			this.playCount = playCount;
			this.imdbId = imdbId;
			this.folder = folder;
			this.trailer = trailer;
			this.genre = genre;
			this.credits = credits;
			this.director = director;
			this.streamDetails = streamDetails;
			this.actors = actors;
			this.watched = watched;
			this.nfo = nfo;
			this.poster = poster;
			this.fanart = fanart;
			this.extraThumbs = extraThumbs;
		}

		@Override
		public String getName() {
			return this.name;
		}

		@Override
		public Integer getYear() {
			return this.year;
		}

		@Override
		public String getOriginalTitle() {
			return this.originalTitle;
		}

		@Override
		public String getSortTitle() {
			return this.sortTitle;
		}

		@Override
		public String getSet() {
			return this.set;
		}

		@Override
		public Double getRating() {
			return this.rating;
		}

		@Override
		public Boolean isTop250() {
			return this.top250;
		}

		@Override
		public Integer getVotes() {
			return this.votes;
		}

		@Override
		public String getOutline() {
			return this.outline;
		}

		@Override
		public String getPlot() {
			return this.plot;
		}

		@Override
		public String getTagLine() {
			return this.tagline;
		}

		@Override
		public Integer getRuntime() {
			return this.runtime;
		}

		@Override
		public String getThumbnail() {
			return this.thumbnail;
		}

		@Override
		public String getMpaa() {
			return this.mpaa;
		}

		@Override
		public Integer getPlayCount() {
			return this.playCount;
		}

		@Override
		public Boolean isWatched() {
			return this.watched;
		}

		@Override
		public String getImdbId() {
			return this.imdbId;
		}

		@Override
		public String getTrailer() {
			return this.trailer;
		}

		@Override
		public String getGenre() {
			return this.genre;
		}

		@Override
		public String getCredits() {
			return this.credits;
		}

		@Override
		public Iterable<DBStreamDetails> getStreamDetails() {
			return this.streamDetails.values();
		}

		@Override
		public String getDirector() {
			return this.director;
		}

		@Override
		public Iterable<DBActor> getActors() {
			return this.actors.values();
		}

		@Override
		public int getMovieId() {
			return this.movieId;
		}

		@Override
		public SourceFolder getFolder() {
			return this.folder;
		}

		@Override
		public SourceFile getNfo() {
			return this.nfo;
		}

		@Override
		public SourceFile getPoster() {
			return this.poster;
		}

		@Override
		public SourceFile getFanart() {
			return this.fanart;
		}

		@Override
		public Iterable<DBExtraThumb> getExtraThumbs() {
			return this.extraThumbs.values();
		}

		@Override
		public int getStreamDetailsCount() {
			return this.streamDetails.size();
		}

		@Override
		public int getActorsCount() {
			return this.actors.size();
		}

		@Override
		public int getExtraThumbsCount() {
			return this.extraThumbs.size();
		}

	}

}
